var React = require('react');
var ReactDom = require('react-dom');
var _ = require('lodash');
import { Link } from 'react-router';
import Menu from 'antd/menu';

export default class Sidebar extends React.Component {

  constructor(props) {
    super(props);
  }

  render() {
    const { props } = this;
    const { content, location, routes } = props;
    var route_paths = _.map(routes.slice(0, -1), function(route, idx){return route.path}),
      route_paths = route_paths.length === 1 && route_paths[0] === '/' ? [] : route_paths,
      route_path = route_paths.join('');
    var curr_route = routes.slice(-1).pop();
    const activeMenuItem = curr_route.path || 'map';

    return (
      <Menu className="aside-container"
            mode="inline"
            selectedKeys={[activeMenuItem]}>
        <Menu.Item key="map">
          <Link to={{pathname: route_path + '/map'}}>地图</Link>
        </Menu.Item>
        <Menu.Item key="listing">
          <Link to={{pathname: route_path + '/listing'}}>列表</Link>
        </Menu.Item>
        <Menu.Item key="data">
          <Link to={{pathname: route_path + '/data'}}>数据</Link>
        </Menu.Item>
      </Menu>
    );
  }

};
